{% extends "blog/base.html" %}
{% load blog_tags %}


{% block content %}
  <h1>{{ post.title }}</h1>
  <h3>
  <small>
    <a href="{% url 'blog:post_edit' post.id %}" >编辑</a>
  </small>
  <small>
    <a href="{% url 'blog:post_del' post.id %}" >删除</a>
  </small>
  <p class="date">
    发布于 {{ post.created }} by {{ post.author }}
  </p></h3>
  <!--{{ post.content|linebreaks }}-->
  {{ post.content|markdown }}
  <p>
  	<a href="{% url 'blog:post_share' post.id %}">分享</a>
  </p>
  <h2>相似文章</h2>
    {% for post in similar_posts %}
      <p>
        <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
      </p>
    {% empty %}
      没有相似的文章。
    {% endfor %}

    {% with comments.count as total_comments %}
      <h2>
         {{ total_comment }} comment{{ total_comment|pluralize }}
      </h2>
    {% endwith %}
    {% for comment in comments %}
      <div class="comment">
         <p class="info">
            Comment {{forloop.counter }} by {{ comment.username }}
            {{ comment.created }}
         </p>
         {{ comment.content|linebreaks }}
      </div>
    {% empty %}
      <p>这篇文章还没有评论，你想成为第一个吗？</p>
    {% endfor %}
  {% if user.is_authenticated %}
    {% if new_comment %}
      <h2>你已经评论这篇文章。</h2>
    {% else %}
      <h2>发表评论：</h2>
      <form action="." method="post">
          {{ comment_form.as_p }}
          {% csrf_token %}
          <p><input type="submit" value="添加"></p>
      </form>
    {% endif %}
  {% else %}
    <p>请<a href="#">登录</a>后再评论</p>
  {% endif %}
{% endblock content %}
